package com.game.data.vo.attribute
{
	import base.BaseVO;
	
	import com.dusk.tool.DataBase;
	import com.game.data.constant.AttributeName;
	
	import config.Config;
	
	public class BaseAttribVO extends BaseVO
	{
		public function BaseAttribVO()
		{
			super();
			_db = new DataBase();
			_db.setDefaultValue(int(0));
		}
		
		protected var _db:DataBase;
		
		/**
		 * 统一接口
		 */
		protected function get gc():Config
		{
			return Config.getIns();
		}
		
		public function get hp():int
		{
			return _db[AttributeName.HP];
		}
		
		/**
		 * 血量百分比(整数！！)
		 * @return int
		 */
		public function getHpPercent():int
		{
			return Math.floor(hp / hpMax * 100);
		}
		
		/**
		 * 魔法值百分比(整数！！)
		 * @return int
		 */
		public function getMpPercent():int
		{
			return Math.floor(mp / mpMax * 100);
		}
		
		public function modifyHpKeepPercent(value:int):void
		{
			var percent:Number = getHpPercent();
			hpMax += value;
			if (hpMax < 0)
			{
				hpMax = 0;
			}
			hp = Math.floor(hpMax * percent);
		}
		
		public function modifyMpKeepPercent(value:int):void
		{
			var percent:Number = getMpPercent();
			mpMax += value;
			if (mpMax < 0)
			{
				mpMax = 0;
			}
			mp = Math.floor(mpMax * percent);
		}
		
		/**
		 * 恢复血量满值
		 */
		public function setFullHp():void
		{
			hp = hpMax;
		}
		
		/**
		 * 恢复魔法值满值
		 */
		public function setFullMp():void
		{
			mp = mpMax;
		}
		
		public function setFullState():void
		{
			setFullHp();
			setFullMp();
		}
		
		/**
		 * 恢复血量
		 * @param value
		 */
		public function cureHp(value:int):void
		{
			hp += value;
			if (hp > hpMax)
			{
				hp = hpMax;
			}
			if (hp < 0)
			{
				hp = 0;
			}
		}
		
		/**
		 * 恢复魔法值
		 * @param value
		 */
		public function cureMp(value:int):void
		{
			mp += value;
			if (mp > mpMax)
			{
				mp = mpMax;
			}
			if (mp < 0)
			{
				mp = 0;
			}
		}
		
		public function reduceHp(value:int):void
		{
			hp -= value;
			if (hp > hpMax)
			{
				hp = hpMax;
			}
			if (hp < 0)
			{
				hp = 0;
			}
		}
		
		public function set hp(value:int):void
		{
			_db[AttributeName.HP] = value;
		}
		
		public function get hpMax():int
		{
			return _db[AttributeName.HP_MAX];
		}
		
		public function set hpMax(value:int):void
		{
			_db[AttributeName.HP_MAX] = value;
		}
		
		public function get hpHeal():int
		{
			return _db[AttributeName.HP_HEAL];
		}
		
		public function set hpHeal(value:int):void
		{
			_db[AttributeName.HP_HEAL] = value;
		}
		
		public function get mp():int
		{
			return _db[AttributeName.MP];
		}
		
		public function set mp(value:int):void
		{
			_db[AttributeName.MP] = value;
		}
		
		public function get mpMax():int
		{
			return _db[AttributeName.MP_MAX];
		}
		
		public function set mpMax(value:int):void
		{
			_db[AttributeName.MP_MAX] = value;
		}
		
		public function get mpHeal():int
		{
			return _db[AttributeName.MP_HEAL];
		}
		
		public function set mpHeal(value:int):void
		{
			_db[AttributeName.MP_HEAL] = value;
		}
		
		public function get atk():int
		{
			return _db[AttributeName.ATK];
		}
		
		public function set atk(value:int):void
		{
			_db[AttributeName.ATK] = value;
		}
		
		public function get def():int
		{
			return _db[AttributeName.DEF];
		}
		
		public function set def(value:int):void
		{
			_db[AttributeName.DEF] = value;
		}
		
		public function get miss():int
		{
			return _db[AttributeName.MISS];
		}
		
		public function set miss(value:int):void
		{
			_db[AttributeName.MISS] = value;
		}
		
		public function get critDamage():int
		{
			return _db[AttributeName.CRIT_DAMAGE];
		}
		
		public function set critDamage(value:int):void
		{
			_db[AttributeName.CRIT_DAMAGE] = value;
		}
		
		public function get deCritDamage():int
		{
			return _db[AttributeName.DE_CRIT_DAMAGE];
		}
		
		public function set deCritDamage(value:int):void
		{
			_db[AttributeName.DE_CRIT_DAMAGE] = value;
		}
		
		public function get magicDef():int
		{
			return _db[AttributeName.MAGIC_DEF];
		}
		
		public function set magicDef(value:int):void
		{
			_db[AttributeName.MAGIC_DEF] = value;
		}
		
		public function get crit():int
		{
			return _db[AttributeName.CRIT];
		}
		
		public function set crit(value:int):void
		{
			_db[AttributeName.CRIT] = value;
		}
		
		public function get hit():int
		{
			return _db[AttributeName.HIT];
		}
		
		public function set hit(value:int):void
		{
			_db[AttributeName.HIT] = value;
		}
		
		public function get deMagicDef():int
		{
			return _db[AttributeName.DE_MAGIC_DEF];
		}
		
		public function set deMagicDef(value:int):void
		{
			_db[AttributeName.DE_MAGIC_DEF] = value;
		}
		
		public function get toughness():int
		{
			return _db[AttributeName.TOUGHNESS];
		}
		
		public function set toughness(value:int):void
		{
			_db[AttributeName.TOUGHNESS] = value;
		}
		
		public function get bloodThirst():int
		{
			return _db[AttributeName.BLOOD_THIRST];
		}
		
		public function set bloodThirst(value:int):void
		{
			_db[AttributeName.BLOOD_THIRST] = value;
		}
		
		public function get magicThirst():int
		{
			return _db[AttributeName.MAGIC_THIRST];
		}
		
		public function set magicThirst(value:int):void
		{
			_db[AttributeName.MAGIC_THIRST] = value;
		}
		
		public function reduceMp(value:int):void
		{
			mp -= value;
			if (mp > mpMax)
			{
				mp = mpMax;
			}
			if (mp < 0)
			{
				mp = 0;
			}
		}
		
		public function update():void
		{
		
		}
	}
}
